3.151 \(\int \frac{f+g x+h x^2}{a+b x+c x^2} \, dx\)

Optimal. Leaf size=92 \[ -\frac{\tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right ) \left (-2 a c h+b^2 h-b c g+2 c^2 f\right )}{c^2 \sqrt{b^2-4 a c}}+\frac{(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}+\frac{h x}{c} \]

[Out]

(h*x)/c - ((2*c^2*f - b*c*g + b^2*h - 2*a*c*h)*ArcTanh[(b + 2*c*x)/Sqrt[b^2 - 4*a*c]])/(c^2*Sqrt[b^2 - 4*a*c])
 + ((c*g - b*h)*Log[a + b*x + c*x^2])/(2*c^2)

________________________________________________________________________________________

Rubi [A]  time = 0.156163, antiderivative size = 92, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 5, integrand size = 23, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.217, Rules used = {1657, 634, 618, 206, 628} \[ -\frac{\tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right ) \left (-2 a c h+b^2 h-b c g+2 c^2 f\right )}{c^2 \sqrt{b^2-4 a c}}+\frac{(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}+\frac{h x}{c} \]

Antiderivative was successfully verified.

[In]

Int[(f + g*x + h*x^2)/(a + b*x + c*x^2),x]

[Out]

(h*x)/c - ((2*c^2*f - b*c*g + b^2*h - 2*a*c*h)*ArcTanh[(b + 2*c*x)/Sqrt[b^2 - 4*a*c]])/(c^2*Sqrt[b^2 - 4*a*c])
 + ((c*g - b*h)*Log[a + b*x + c*x^2])/(2*c^2)

Rule 1657

Int[(Pq_)*((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegrand[Pq*(a + b*x + c*x^2)^p, x
], x] /; FreeQ[{a, b, c}, x] && PolyQ[Pq, x] && IGtQ[p, -2]

Rule 634

Int[((d_.) + (e_.)*(x_))/((a_) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> Dist[(2*c*d - b*e)/(2*c), Int[1/(a +
 b*x + c*x^2), x], x] + Dist[e/(2*c), Int[(b + 2*c*x)/(a + b*x + c*x^2), x], x] /; FreeQ[{a, b, c, d, e}, x] &
& NeQ[2*c*d - b*e, 0] && NeQ[b^2 - 4*a*c, 0] &&  !NiceSqrtQ[b^2 - 4*a*c]

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 206

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTanh[(Rt[-b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[-b, 2]), x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 628

Int[((d_) + (e_.)*(x_))/((a_.) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> Simp[(d*Log[RemoveContent[a + b*x +
c*x^2, x]])/b, x] /; FreeQ[{a, b, c, d, e}, x] && EqQ[2*c*d - b*e, 0]

Rubi steps

\begin{align*} \int \frac{f+g x+h x^2}{a+b x+c x^2} \, dx &=\int \left (\frac{h}{c}+\frac{c f-a h+(c g-b h) x}{c \left (a+b x+c x^2\right )}\right ) \, dx\\ &=\frac{h x}{c}+\frac{\int \frac{c f-a h+(c g-b h) x}{a+b x+c x^2} \, dx}{c}\\ &=\frac{h x}{c}+\frac{(c g-b h) \int \frac{b+2 c x}{a+b x+c x^2} \, dx}{2 c^2}+\frac{\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \int \frac{1}{a+b x+c x^2} \, dx}{2 c^2}\\ &=\frac{h x}{c}+\frac{(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}-\frac{\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \operatorname{Subst}\left (\int \frac{1}{b^2-4 a c-x^2} \, dx,x,b+2 c x\right )}{c^2}\\ &=\frac{h x}{c}-\frac{\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \tanh ^{-1}\left (\frac{b+2 c x}{\sqrt{b^2-4 a c}}\right )}{c^2 \sqrt{b^2-4 a c}}+\frac{(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}\\ \end{align*}

Mathematica [A]  time = 0.0710634, size = 95, normalized size = 1.03 \[ \frac{\tan ^{-1}\left (\frac{b+2 c x}{\sqrt{4 a c-b^2}}\right ) \left (-2 a c h+b^2 h-b c g+2 c^2 f\right )}{c^2 \sqrt{4 a c-b^2}}+\frac{(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}+\frac{h x}{c} \]

Antiderivative was successfully verified.

[In]

Integrate[(f + g*x + h*x^2)/(a + b*x + c*x^2),x]

[Out]

(h*x)/c + ((2*c^2*f - b*c*g + b^2*h - 2*a*c*h)*ArcTan[(b + 2*c*x)/Sqrt[-b^2 + 4*a*c]])/(c^2*Sqrt[-b^2 + 4*a*c]
) + ((c*g - b*h)*Log[a + b*x + c*x^2])/(2*c^2)

________________________________________________________________________________________

Maple [B]  time = 0.175, size = 196, normalized size = 2.1 \begin{align*}{\frac{hx}{c}}-{\frac{\ln \left ( c{x}^{2}+bx+a \right ) bh}{2\,{c}^{2}}}+{\frac{\ln \left ( c{x}^{2}+bx+a \right ) g}{2\,c}}-2\,{\frac{ah}{c\sqrt{4\,ac-{b}^{2}}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) }+2\,{\frac{f}{\sqrt{4\,ac-{b}^{2}}}\arctan \left ({\frac{2\,cx+b}{\sqrt{4\,ac-{b}^{2}}}} \right ) }+{\frac{{b}^{2}h}{{c}^{2}}\arctan \left ({(2\,cx+b){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}} \right ){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}}-{\frac{bg}{c}\arctan \left ({(2\,cx+b){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}} \right ){\frac{1}{\sqrt{4\,ac-{b}^{2}}}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((h*x^2+g*x+f)/(c*x^2+b*x+a),x)

[Out]

h*x/c-1/2/c^2*ln(c*x^2+b*x+a)*b*h+1/2/c*ln(c*x^2+b*x+a)*g-2/c/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(
1/2))*a*h+2/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*f+1/c^2/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(
4*a*c-b^2)^(1/2))*b^2*h-1/c/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)/(4*a*c-b^2)^(1/2))*b*g

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x^2+g*x+f)/(c*x^2+b*x+a),x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [A]  time = 1.62718, size = 670, normalized size = 7.28 \begin{align*} \left [\frac{2 \,{\left (b^{2} c - 4 \, a c^{2}\right )} h x -{\left (2 \, c^{2} f - b c g +{\left (b^{2} - 2 \, a c\right )} h\right )} \sqrt{b^{2} - 4 \, a c} \log \left (\frac{2 \, c^{2} x^{2} + 2 \, b c x + b^{2} - 2 \, a c + \sqrt{b^{2} - 4 \, a c}{\left (2 \, c x + b\right )}}{c x^{2} + b x + a}\right ) +{\left ({\left (b^{2} c - 4 \, a c^{2}\right )} g -{\left (b^{3} - 4 \, a b c\right )} h\right )} \log \left (c x^{2} + b x + a\right )}{2 \,{\left (b^{2} c^{2} - 4 \, a c^{3}\right )}}, \frac{2 \,{\left (b^{2} c - 4 \, a c^{2}\right )} h x - 2 \,{\left (2 \, c^{2} f - b c g +{\left (b^{2} - 2 \, a c\right )} h\right )} \sqrt{-b^{2} + 4 \, a c} \arctan \left (-\frac{\sqrt{-b^{2} + 4 \, a c}{\left (2 \, c x + b\right )}}{b^{2} - 4 \, a c}\right ) +{\left ({\left (b^{2} c - 4 \, a c^{2}\right )} g -{\left (b^{3} - 4 \, a b c\right )} h\right )} \log \left (c x^{2} + b x + a\right )}{2 \,{\left (b^{2} c^{2} - 4 \, a c^{3}\right )}}\right ] \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x^2+g*x+f)/(c*x^2+b*x+a),x, algorithm="fricas")

[Out]

[1/2*(2*(b^2*c - 4*a*c^2)*h*x - (2*c^2*f - b*c*g + (b^2 - 2*a*c)*h)*sqrt(b^2 - 4*a*c)*log((2*c^2*x^2 + 2*b*c*x
 + b^2 - 2*a*c + sqrt(b^2 - 4*a*c)*(2*c*x + b))/(c*x^2 + b*x + a)) + ((b^2*c - 4*a*c^2)*g - (b^3 - 4*a*b*c)*h)
*log(c*x^2 + b*x + a))/(b^2*c^2 - 4*a*c^3), 1/2*(2*(b^2*c - 4*a*c^2)*h*x - 2*(2*c^2*f - b*c*g + (b^2 - 2*a*c)*
h)*sqrt(-b^2 + 4*a*c)*arctan(-sqrt(-b^2 + 4*a*c)*(2*c*x + b)/(b^2 - 4*a*c)) + ((b^2*c - 4*a*c^2)*g - (b^3 - 4*
a*b*c)*h)*log(c*x^2 + b*x + a))/(b^2*c^2 - 4*a*c^3)]

________________________________________________________________________________________

Sympy [B]  time = 2.03855, size = 488, normalized size = 5.3 \begin{align*} \left (- \frac{\sqrt{- 4 a c + b^{2}} \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \left (4 a c - b^{2}\right )} - \frac{b h - c g}{2 c^{2}}\right ) \log{\left (x + \frac{- a b h - 4 a c^{2} \left (- \frac{\sqrt{- 4 a c + b^{2}} \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \left (4 a c - b^{2}\right )} - \frac{b h - c g}{2 c^{2}}\right ) + 2 a c g + b^{2} c \left (- \frac{\sqrt{- 4 a c + b^{2}} \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \left (4 a c - b^{2}\right )} - \frac{b h - c g}{2 c^{2}}\right ) - b c f}{2 a c h - b^{2} h + b c g - 2 c^{2} f} \right )} + \left (\frac{\sqrt{- 4 a c + b^{2}} \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \left (4 a c - b^{2}\right )} - \frac{b h - c g}{2 c^{2}}\right ) \log{\left (x + \frac{- a b h - 4 a c^{2} \left (\frac{\sqrt{- 4 a c + b^{2}} \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \left (4 a c - b^{2}\right )} - \frac{b h - c g}{2 c^{2}}\right ) + 2 a c g + b^{2} c \left (\frac{\sqrt{- 4 a c + b^{2}} \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \left (4 a c - b^{2}\right )} - \frac{b h - c g}{2 c^{2}}\right ) - b c f}{2 a c h - b^{2} h + b c g - 2 c^{2} f} \right )} + \frac{h x}{c} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x**2+g*x+f)/(c*x**2+b*x+a),x)

[Out]

(-sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h - c*g)/(2*c**2))*lo
g(x + (-a*b*h - 4*a*c**2*(-sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) -
 (b*h - c*g)/(2*c**2)) + 2*a*c*g + b**2*c*(-sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*
(4*a*c - b**2)) - (b*h - c*g)/(2*c**2)) - b*c*f)/(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)) + (sqrt(-4*a*c + b**2)
*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h - c*g)/(2*c**2))*log(x + (-a*b*h - 4*a*c
**2*(sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h - c*g)/(2*c**2))
 + 2*a*c*g + b**2*c*(sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h
- c*g)/(2*c**2)) - b*c*f)/(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)) + h*x/c

________________________________________________________________________________________

Giac [A]  time = 1.13261, size = 120, normalized size = 1.3 \begin{align*} \frac{h x}{c} + \frac{{\left (c g - b h\right )} \log \left (c x^{2} + b x + a\right )}{2 \, c^{2}} + \frac{{\left (2 \, c^{2} f - b c g + b^{2} h - 2 \, a c h\right )} \arctan \left (\frac{2 \, c x + b}{\sqrt{-b^{2} + 4 \, a c}}\right )}{\sqrt{-b^{2} + 4 \, a c} c^{2}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x^2+g*x+f)/(c*x^2+b*x+a),x, algorithm="giac")

[Out]

h*x/c + 1/2*(c*g - b*h)*log(c*x^2 + b*x + a)/c^2 + (2*c^2*f - b*c*g + b^2*h - 2*a*c*h)*arctan((2*c*x + b)/sqrt
(-b^2 + 4*a*c))/(sqrt(-b^2 + 4*a*c)*c^2)